home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7594 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: jacare.zk3.dec.com!zeeb
  2. From: zeeb@jacare.zk3.dec.com (Jeff Zeeb DEC C)
  3. Newsgroups: comp.lang.pl1,comp.lang.c
  4. Subject: Re: PL/I and C
  5. Date: 26 Feb 1996 14:41:49 GMT
  6. Organization: Digital Equipment Corporation
  7. Distribution: world
  8. Message-ID: <4gsgrd$v7u@zk2nws.zko.dec.com>
  9. References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <312CCEB2.4AB7@corp.dialog.com> <AD536AAB9668B76CD@mcdialb09.it.luc.edu> <312E363C.3CDE@corp.dialog.com> <AD53AB1396681879FA@mcdialb10.it.luc.edu>
  10. Reply-To: zeeb@decc.enet.dec.com
  11. NNTP-Posting-Host: jacare.zk3.dec.com
  12. X-Newsreader: mxrn 6.18-32
  13.  
  14.  
  15. In article <AD53AB1396681879FA@mcdialb10.it.luc.edu>, VArase@varase.it.luc.edu (Verne Arase) writes:
  16.  
  17. >... and BTW, you don't need to use a union; you can simply have several
  18. >pointers, each containing the same address. Just coerce them with a cast.
  19. >
  20. >   foo *x;
  21. >   bar *y;
  22. >
  23. >   y=(bar *) x;
  24.  
  25. This is dangerous territory.  The code fragment above violates the
  26. aliasing rules in the ANSI C standard.  In a nutshell, those rules
  27. state that a pointer to one type will not point to an object of a
  28. different type.  An optimizer could generate code using this assumption,
  29. which would have unexpected results in your program.
  30.  
  31. --
  32. Jeff Zeeb                  This article represents my opinions and not those
  33. zeeb@decc.enet.dec.com     of Digital Equipment Corp. (Surprise!)
  34.